package eteam.aps.systeminterface.service;

import eteam.aps.common.R;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.common.exceptions.BusinessException;
import eteam.aps.systeminterface.model.dto.VerifyTokenDto;
import eteam.aps.systeminterface.model.entity.UserEntity;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 用户授权控制器
 */
public interface IAuthController {
    /**
     * 构建用户Token
     *
     * @param username: 用户名
     * @param password: 密码
     * @return: 用户Token信息
     */
    @RequestMapping(value = {"/api/auth/buildtoken"}, method = {RequestMethod.GET})
    R<UserEntity> buildToken(
            @NotBlank(message = "用户名为空") @RequestParam("username") String username,
            @NotBlank(message = "密码为空") @RequestParam("password") String password
    ) throws Exception, AuthException, BusinessException;

    /**
     * 校验Token是否合法
     *
     * @param token: token信息
     * @return: 返回用户信息
     */
    @RequestMapping(value = {"/api/auth/verifytoken"}, method = {RequestMethod.GET})
    R<VerifyTokenDto> verifyToken(
            @NotBlank(message = "Token为空") @RequestHeader(value = "token") String token
    ) throws Exception, AuthException, BusinessException;

    /**
     * 获取当前用户的权限Key列表
     *
     * @return: 权限列表
     */
    @RequestMapping(value = "/api/auth/getuclist", method = RequestMethod.GET)
    R<List<String>> getUcList() throws Exception, AuthException;
}
